package bluetooth.data;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import bluetooth.model.Product;

import com.google.gson.Gson;

public final class DeserializeData {

	private static String json_data;
	public static List<Product> products = new ArrayList<Product> ();
	
	public static void deserializeJsonData (String json){
		products = new ArrayList<Product> ();
		Gson gson = new Gson ();
		Product [] obj = gson.fromJson(json, Product[].class);	
	    products.addAll(Arrays.asList(obj));	
	}

	public static List<Product> getProducts() {
		return products;
	}

	public static void setProducts(List<Product> products) {
		DeserializeData.products = products;
	}
	
	public static String getJsonData(){
		
		return json_data;
	}
	
	public static String getJsonFromUpdatedDataList (){
		
		
		String json = new Gson().toJson( products);
		json +="\r\n";
		return json;
	}

	public static void setJsonData(String lineRead) {
		// TODO Auto-generated method stub
		json_data=lineRead;
	}
	
	
}
